<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类式组件</title>
    <style>
        header{
            height: 100px;
            background: #aef;
        }

        section{
            height: 400px;
            background: rgb(42, 88, 19);
        }

        footer{
            height: 100px;
            background: #c65;
        }
    </style>
</head>
<body>
    <div id="root"></div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        //类的复习
        // class A{
        //     run(){
        //         console.log('AAA');
        //     }
        // }
        // class B extends A{}
        // let b = new B();
        // b.run();


        //类式组件
        class Top extends React.Component{
            //声明的一个方法
            render(){
                return <header>顶部</header>
            }
        }

        class Main extends React.Component{
            render(){
                return <section>内容</section>;
            }
        }

        class Bottom extends React.Component{
            render(){
                return <footer>尾部</footer>
            }
        }


        //创建虚拟 DOM 对象   Top 内部会实例化 Top 对象, 然后调用 render 方法返回虚拟 DOM 对象
        // let vDOM = <div>
        //         <Top></Top>
        //         <Main></Main>
        //         <Bottom />
        //     </div>; 
    
        class App extends React.Component{
            render(){
                return <div>
                            <Top></Top>
                            <Main></Main>
                            <Bottom />
                        </div>
            }
        }
        
        //渲染
        ReactDOM.render(<App></App>, document.querySelector("#root"));
    </script>
</body>
</html>